package com.tangsm.spring.boot.validation.domain.vo;

import java.io.Serializable;
import java.util.List;

/**
 * 分页视图对象
 *
 * @author tangsm
 */
public class Page<T> implements Serializable {
    /**
     * 分页数据
     */
    private List<T> data;

    /**
     * 总条数
     */
    private Integer total;

    /**
     * 总页数
     */
    private Integer pages;

    /**
     * 当前页
     */
    private Integer current;

    /**
     * 查询数量
     */
    private Integer size;

    /**
     * 设置总记录数
     *
     * @param total 总记录数
     */
    public void setTotal(Integer total) {
        this.total = total;
        this.setPages(this.total % this.size > 0 ? this.total / this.size + 1 : this.total / this.size);
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public Integer getTotal() {
        return total;
    }

    public Integer getPages() {
        return pages;
    }

    public void setPages(Integer pages) {
        this.pages = pages;
    }

    public Integer getCurrent() {
        return current;
    }

    public void setCurrent(Integer current) {
        this.current = current;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    @Override
    public String toString() {
        return "PageVo{" +
                "data=" + data +
                ", total=" + total +
                ", pages=" + pages +
                ", current=" + current +
                ", size=" + size +
                '}';
    }
}
